﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Adventureplanner
{
    class Adventure
    {
        private String title { get; set; }
        private String description { get; set; }
        private List<Character> characters;
        private List<Subplot> plots;
        private List<Npc> npcs;
        private List<Location> locations;
        private List<Speciality> specials;
        private List<Con_npc_location> cnl;
        private List<Con_npc_speciality> cns;
        private List<Con_plot_location> cpl;
        private List<Con_plot_npc> cpn;
        private List<Con_plot_speciality> cps;
        private List<Con_speciality_location> csl;

        public Adventure(String title)
        {
            this.title = title;
            this.characters = new List<Character>();
            this.plots = new List<Subplot>();
            this.npcs = new List<Npc>();
            this.locations = new List<Location>();
            this.specials = new List<Speciality>();
            this.cnl = new List<Con_npc_location>();
            this.cns = new List<Con_npc_speciality>();
            this.cpl = new List<Con_plot_location>();
            this.cpn = new List<Con_plot_npc>();
            this.cps = new List<Con_plot_speciality>();
            this.csl = new List<Con_speciality_location>();
            this.description = "";
        }

        public int getLastCharactersId() {
            int id = 0;
            foreach (Character c in characters) {
                if (c.id > id) {
                    id = c.id;
                }
            }
            return id;
        }

        public int addCharacter(String name) {
            int id = getLastCharactersId();
            Character character = new Character(id, name);
            this.characters.Add(character);
            return id;
        }

        public List<Character> getAllCharacters() {
            return this.characters;
        }

        public int getCharacterByName(String name) {
            int id = 0;
            foreach (Character c in characters) {
                if (c.name == name) {
                    id = c.id;
                }
            }
            return id;
        }

        public Boolean editCharacter(int id, String name, String notes, String boost, String weaken) {
            return true;
        }

//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
        //Subplot

        public int getLastSubplotsId()
        {
            int id = 0;
            foreach (Subplot c in plots)
            {
                if (c.id > id){
                    id = c.id;
                }
            }
            return id;
        }

        public int addSubplot(String name)
        {
            int id = getLastSubplotsId();
            Subplot plots = new Subplot(id, name);
            this.plots.Add(plots);
            return id;
        }

        public List<Subplot> getAllSubplots()
        {
            return this.plots;
        }

        public int getSubplotByName(String name)
        {
            int id = 0;
            foreach (Subplot c in plots)
            {
                if (c.name == name)
                {
                    id = c.id;
                }
            }
            return id;
        }

        public Boolean editSubplot(int id, String name, String notes, String boost, String weaken)
        {
            return true;
        }

//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
        //Npc
        public int getLastNpcsId()
        {
            int id = 0;
            foreach (Npc c in npcs)
            {
                if (c.id > id)
                {
                    id = c.id;
                }
            }
            return id;
        }

        public int addNpc(String name)
        {
            int id = getLastNpcsId();
            Npc npcs = new Npc(id, name);
            this.npcs.Add(npcs);
            return id;
        }

        public List<Npc> getAllNpcs()
        {
            return this.npcs;
        }

        public int getNpcByName(String name)
        {
            int id = 0;
            foreach (Npc c in npcs)
            {
                if (c.name == name)
                {
                    id = c.id;
                }
            }
            return id;
        }

        public Boolean editNpc(int id, String name, String notes, String boost, String weaken)
        {
            return true;
        }
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
        //location
        public int getLastLocationsId()
        {
            int id = 0;
            foreach (Location c in locations)
            {
                if (c.id > id)
                {
                    id = c.id;
                }
            }
            return id;
        }

        public int addLocation(String name)
        {
            int id = getLastLocationsId();
            Location locations  = new Location(id, name);
            this.locations.Add(locations);
            return id;
        }

        public List<Location> getAllLocations()
        {
            return this.locations;
        }

        public int getLocationByName(String name)
        {
            int id = 0;
            foreach (Location c in locations)
            {
                if (c.name == name)
                {
                    id = c.id;
                }
            }
            return id;
        }

        public Boolean editLocation(int id, String name, String notes, String boost, String weaken)
        {
            return true;
        }
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
        //Speciality
        public int getLastSpecialitysId()
        {
            int id = 0;
            foreach (Speciality c in specials)
            {
                if (c.id > id)
                {
                    id = c.id;
                }
            }
            return id;
        }

        public int addSpeciality(String name)
        {
            int id = getLastSpecialitysId();
            Speciality specials = new Speciality(id, name);
            this.specials.Add(specials);
            return id;
        }

        public List<Speciality> getAllSpeciality()
        {
            return this.specials;
        }

        public int getSpecialityByName(String name)
        {
            int id = 0;
            foreach (Speciality c in specials)
            {
                if (c.name == name)
                {
                    id = c.id;
                }
            }
            return id;
        }

        public Boolean editSpeciality(int id, String name, String notes, String boost, String weaken)
        {
            return true;
        }
    }
}
